﻿using System;
using System.Collections.Generic;
using System.Text;
//using CacheHelper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
//using NoticePlugin;
//using NoticePlugin.IService;
//using MQHelper.MQ;
using XKPlatform.Common.Const;

namespace XKPlatform.Controllers
{
    public class HomeController : Controller
    {
        //private readonly IHandleRabbitMQ _handleRabbitMQ;
        //public HomeController(IHandleRabbitMQ handleRabbitMQ)
        //{
        //    _handleRabbitMQ = handleRabbitMQ;
        //}

        //private readonly ICache _iCache;
        //public HomeController(ICache iCache)
        //{
        //    _iCache = iCache;
        //}

        //private readonly INoticeService _noticeService;
        public HomeController()
        {
            //_noticeService = noticeService;
        }

        [AllowAnonymous]
        public RedirectResult Index()
        {
            //_iCache.Set("test", "test111", new System.TimeSpan(0, 0, 10));

            //_iCache.ExpiredMonitor((channel, message) =>
            //{
            //    //输出收到的消息
            //    Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] ====={channel}====={message}");
            //});

            //_handleRabbitMQ.PublishMsg("myqueue", "test");
            //Console.WriteLine($"成功发送消息:test");
            //_handleRabbitMQ.Received("myqueue", (model, ea) =>
            //{
            //    Console.WriteLine($"成功消费消息：" + Encoding.UTF8.GetString(ea.Body.ToArray()));
            //});

            //_handleRabbitMQ.TaskPublishMsg(GlobleConst.RabbitMQTaskExchange, GlobleConst.RabbitMQaskRoutingKey, "10000", "test");
            //Console.WriteLine($"成功发送消息:test,时间：{DateTime.Now:yyyy-MM-dd HH:mm:ss}");

            //_handleRabbitMQ.TaskReceived("delay_queue1", "delay", "delay_key", (model, ea) =>
            //{
            //    byte[] message = ea.Body.ToArray();//接收到的消息
            //    Console.WriteLine(string.Format("接收到信息为：{0},时间：{1}", Encoding.UTF8.GetString(message), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            //});

            //throw new NullReferenceException("测试错误！");
            //string emailContent = $"<p>Hi</p ><p>您在BuyCoffe管理后台申请的账号为：【test】密码为：【test】，申请时间：【{DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒")}】</p ><p><a href=\"https://buycoffee.nestlechinese.com/views/index.html#/admin/login\" rel=\"noopener\">点击这里访问BuyCoffe管理后台</a ></p ><p></p ><p>如果上面的链接无法打开，请复制以下链接至浏览器上 https://buycoffee.nestlechinese.com/views/index.html#/admin/login </p ><p>如果您没有申请账号，请忽略这封邮件。</p ><p>如有疑问可发送邮件至：service@zysdk.com</p ><p>备注：此邮件为系统自动发送，回复此邮件无效</p ><br>";
            //_noticeService.SendEmailMsg("service@zysdk.com", "service@zysdk.com", new List<string> { "vipitsoft@163.com" }, "smtp.exmail.qq.com", 25, "service@zysdk.com", "fb7AxX2smXCoPXVY", "BuyCoffe创建账号", emailContent);

            return Redirect("/views/index.html#/admin/login");
            //return Redirect("/views/analysis/map_new.html");
        }
    }
}